package streams;

import java.io.*;


public class LearningStreams {

    private static String filePath = "/home/joshua/IdeaProjects/streams/resources";


    public static void main(String[] args) throws IOException {
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream(filePath + "/" + "fileIn.log");
            out = new FileOutputStream(filePath + "/" + "fileOut.log");
        } catch (FileNotFoundException e) {
            //e.printStackTrace();
            System.err.printf("%s", "File not found or file unreadable");
            System.exit(0);
        }
        readFile(in, out);
    }


    public static void readFile(FileInputStream inStream, FileOutputStream outStream) throws IOException {

        int len;

        while((len = inStream.read()) != -1){
            outStream.write(len);
        }

        inStream.close();
        outStream.close();
    }
}
